import express, { Router } from 'express';
import { UserController } from '../controllers/UserController';
import { authMiddleware } from '../middleware/auth';
import { validate, updateProfileValidation, changePasswordValidation } from '../middleware/validation';
import { avatarUploadMiddleware } from '../middleware/avatarUpload';

const router: Router = express.Router();
const userController = new UserController();

// 获取用户信息 (需要认证)
router.get('/profile', authMiddleware, userController.getProfile);

// 更新用户信息 (需要认证)
router.put('/profile', authMiddleware, validate(updateProfileValidation), userController.updateProfile);

// 修改密码 (需要认证)
router.post('/change-password', authMiddleware, validate(changePasswordValidation), userController.changePassword);

// 获取用户统计数据 (需要认证)
router.get('/stats', authMiddleware, userController.getStats);

// 上传用户头像 (需要认证)
router.post('/avatar', authMiddleware, avatarUploadMiddleware.single('avatar'), userController.uploadAvatar);

// 删除用户头像 (需要认证)
router.delete('/avatar', authMiddleware, userController.deleteAvatar);

// 获取用户活动记录 (需要认证)
router.get('/activities', authMiddleware, userController.getActivities);

export default router;